package com.sss.gsb.ws.enpoints;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;

import com.sss.gsb.message.schemas.LoanAccountClosedRequest;
import com.sss.gsb.message.schemas.LoanAccountClosedResponse;
import com.sss.gsb.orm.model.LoanAccountClosed;
import com.sss.gsb.service.LoadParameter;
import com.sss.gsb.service.impl.LoanAccountClosedService;
import com.sss.gsb.util.SchemaConvertionUtils;

@Deprecated
@Endpoint
public class CPKLoanAccClosedTransactionEndpoint implements CPKEndpoint {
	private static final Logger log = LoggerFactory.getLogger(CPKLoanAccClosedTransactionEndpoint.class);
	
	@Autowired
	private LoanAccountClosedService service;
	
	@PayloadRoot(localPart="LoanAccountClosedRequest", namespace = NAMESPACE)
	public LoanAccountClosedResponse getDeptBalance(LoanAccountClosedRequest request){
		log.info("Loading Loan account closed transaction endpoint...");
		try{
			LoadParameter param = SchemaConvertionUtils.toLoadParameter(request);
			List<LoanAccountClosed> result = this.service.loadData(param);
			LoanAccountClosedResponse response = new LoanAccountClosedResponse();
			for(LoanAccountClosed lac: result){
				response.getLoanAccClosed().add(SchemaConvertionUtils.toSchema(lac));
			}
			return response; 
		}
		catch(Exception e){
			log.error("Could not load data from endpoint :: ["+e.getMessage()+"]",e);
		}
		return null;
	}
}
